package com.ruoyi.project.loan.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.project.loan.domain.LoanProduct;
import com.ruoyi.project.loan.mapper.LoanProductMapper;
import com.ruoyi.project.loan.service.ILoanProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 贷款产品Service业务层处理
 *
 * @author ruoyi
 * @date 2025-11-11
 */
@Service
public class LoanProductServiceImpl implements ILoanProductService {
    @Autowired
    private LoanProductMapper loanProductMapper;

    /**
     * 查询贷款产品
     *
     * @param productId 贷款产品主键
     * @return 贷款产品
     */
    @Override
    public LoanProduct selectLoanProductByProductId(Long productId) {
        return loanProductMapper.selectLoanProductByProductId(productId);
    }

    /**
     * 查询贷款产品列表
     *
     * @param loanProduct 贷款产品
     * @return 贷款产品
     */
    @Override
    public List<LoanProduct> selectLoanProductList(LoanProduct loanProduct) {
        return loanProductMapper.selectLoanProductList(loanProduct);
    }

    /**
     * 新增贷款产品
     *
     * @param loanProduct 贷款产品
     * @return 结果
     */
    @Override
    public int insertLoanProduct(LoanProduct loanProduct) {
        loanProduct.setCreateTime(DateUtils.getNowDate());
        return loanProductMapper.insertLoanProduct(loanProduct);
    }

    /**
     * 修改贷款产品
     *
     * @param loanProduct 贷款产品
     * @return 结果
     */
    @Override
    public int updateLoanProduct(LoanProduct loanProduct) {
        loanProduct.setUpdateTime(DateUtils.getNowDate());
        return loanProductMapper.updateLoanProduct(loanProduct);
    }

    /**
     * 批量删除贷款产品
     *
     * @param productIds 需要删除的贷款产品主键
     * @return 结果
     */
    @Override
    public int deleteLoanProductByProductIds(Long[] productIds) {
        return loanProductMapper.deleteLoanProductByProductIds(productIds);
    }

    /**
     * 删除贷款产品信息
     *
     * @param productId 贷款产品主键
     * @return 结果
     */
    @Override
    public int deleteLoanProductByProductId(Long productId) {
        return loanProductMapper.deleteLoanProductByProductId(productId);
    }
}
